/*
 * @Author: samfeng
 * @Date: 2021-04-11 14:27:39
 * @LastEditTime: 2021-04-24 13:20:01
 * @LastEditors: Please set LastEditors
 * @Description: 左边展示滚动list
 * @FilePath: /first_flutter_app/lib/indexPage/leftGuide.dart
 */

import 'package:first_flutter_app/constant/dataInfo.dart';
import 'package:first_flutter_app/util/IconText.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

Widget leftGaide() {
  return Container(
    color: Colors.blue,
    width: ScreenUtil().setWidth(100),
    child: Stack(
      children: [
        myListViewSeparated(),
        myPosition()
      ],
    ),
  );
}

Widget myPosition() {
  return Positioned(
      bottom: 1,
      child: Container(
        width: ScreenUtil().setWidth(100),
        color: Colors.green,
        child: myIconText(),
      ));
}

Widget myIconText() {
  return Padding(
    padding: EdgeInsets.only(bottom: ScreenUtil().setHeight(80)),
    child: IconText("封云森",
        icon: Icon(Icons.person),
        iconSize: 30.0,
        direction: Axis.vertical,
        style: TextStyle(
          color: Colors.white,
          fontSize: 15,
        )),
  );
}

Widget myListViewSeparated() {
  return ListView.separated(
    shrinkWrap: true,
    itemBuilder: (context, i) {
      return buildListData(context, titleList[i], iconList[i]);
    },
    separatorBuilder: (BuildContext context, int index) {
      return Divider();
    },
    itemCount: titleList.length,
  );
}

Widget buildListData(
  BuildContext context,
  String titleItem,
  Icon iconItem,
) {
  return ListTile(
    title: iconItem,
    subtitle: Text(
      titleItem,
      textAlign: TextAlign.center,
      style: TextStyle(fontSize: ScreenUtil().setSp(50), color: Colors.white),
    ),
    // trailing: Icon(Icons.keyboard_arrow_right),
    onTap: () {
      showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text(
              'ListViewAlert',
              style: TextStyle(
                color: Colors.black54,
                fontSize: 15.0,
              ),
            ),
            content: Text('选择的item内容为:$titleItem'),
          );
        },
      );
    },
  );
}
